/*
 * Copyright (c) 2016-2019 fafa.com.cn. All Rights Reserved.
 */

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * list集合工具类
 *
 * @author Roninwz
 * @date 2019/1/22 下午16:30
 * @since 1.0.0
 */

public class ListUtil {


    /**
     * 获取list 型集合中出现次数最大的数
     * @param list
     * @return
     */
    private static <T> T getMaxAppearObjectNum(List<T> list){
        T num = null;
        int a = -1;
        Map<T, Integer> map = new HashMap<>();
        for (T item : list) {
            if (map.containsKey(item)) {
                map.put(item, map.get(item) + 1);
            } else {
                map.put(item, 1);
            }
        }
        for (T key : map.keySet()) {
            if (a < map.get(key)) {
                a = map.get(key);
                num = key;
            }
        }

        return num;
    }
}
